package calcul;

import java.io.*;

public class TextFileCalculator {

	final static String PATH_IN = (new File("geo2.txt")).getAbsolutePath();
	final static String PATH_OUT = (new File("out.txt")).getAbsolutePath();

	public static void main(String Args[]){
		BufferedReader br;
		BufferedWriter bw;
		int error = 0;
		try {			
			br = new BufferedReader(new FileReader(PATH_IN));
			bw = new BufferedWriter(new FileWriter(PATH_OUT));
			String line;
			Parser parser = new Parser();
			while((line = br.readLine()) != null) {
				try {
					bw.write(String.valueOf(parser.parse(line)));
				} catch (Exception e) {
					error++;
					bw.write(String.valueOf(e));
				}
				bw.newLine();
			}
			br.close();
			bw.close();
		}		
		catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("Process completed with " + error + " errors.");
	}
}
